package ch06.home;

class Exercise6_23 {
	public static int max(int[] arr) {
		if (arr == null || arr.length == 0)	return -999999;
		int max = arr[0];
		for (int i = 1; i < arr.length; i++)
			if (arr[i] > max) max = arr[i];
		return max;
	}

	public static void main(String[] args) {
		int[] data = { 3, 2, 9, 4, 7 };
		System.out.println(java.util.Arrays.toString(data));
		System.out.println("max: " + max(data));
		System.out.println("max: " + max(null));
		System.out.println("max: " + max(new int[] {}));
	}
}
/*
[3, 2, 9, 4, 7]
max: 9
max: -999999
max: -999999
*/
